package max.ta.data.access;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;

import junit.framework.TestCase;
import max.ta.data.entity.StockQuote;

import org.apache.log4j.Logger;

public class StockeQuoteCSVLoaderTest
	extends TestCase {

    private static final Logger logger = Logger.getLogger(StockeQuoteCSVLoaderTest.class);
    private static final CSVDataLoader<StockQuote> LOADER = new StockeQuoteCSVLoader();
    private static final File CSV_FILE = new File("data/IBM.csv");

    public void testLoad() throws IOException {
	try {
	    assertTrue(CSV_FILE.exists());
	    List<StockQuote> quotes = LOADER.load(CSV_FILE);
	    for (StockQuote q : quotes) {
		logger.info(q);
	    }
	} catch (IOException e) {
	    e.printStackTrace();
	    throw e;
	}
    }
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("M/d/yyyy");

    public void testDateFormat() throws  Exception {
	try {
	    logger.info(DATE_FORMAT.parse("10/7/2011"));
	} catch ( Exception e) {
	    e.printStackTrace();
	    throw e;
	}
    }


}
